package com.sykj.springboot.test.designMode.singletonPattern;

public class Emperor {

    //这种方式不能保证单例是一个单例
//    private static Emperor emperor = null;


    //能简单的、彻底解决问题
    private static Emperor emperor = new Emperor();


    //约束不能生成新实例
    private Emperor() {
    }

    public static Emperor getInstance(){
        if (emperor == null) {
            emperor = new Emperor();
        }
        return emperor;
    }


}
